﻿global using Microsoft.EntityFrameworkCore.Metadata.Builders;

global using System.ComponentModel.DataAnnotations.Schema;

global using Microsoft.EntityFrameworkCore;

namespace WXWorkSvc.Common.Data;

[EntityTypeConfiguration(typeof(TAgentConfig))]
public class TAgent
{
    [StringLength(32)]
    public string SuiteId { get; set; } = default!;
    [StringLength(32)]
    public string CorpId { get; set; } = default!;
    public int AgentId { get; set; }
    public string PermanentCode { get; set; } = default!;
    public string Token { get; set; } = "";
    public DateTime DTExpiresToken { get; set; }
    public string JsTicket { get; set; } = "";
    public string AgentJsTicket { get; set; } = "";
    public DateTime DTExpiresTicket { get; set; }
    [ForeignKey(nameof(SuiteId))]
    public virtual TSuite Suite { get; set; } = default!;
    [ForeignKey(nameof(CorpId))]
    public virtual TCorp Corp { get; set; } = default!;
}

public class TAgentConfig : IEntityTypeConfiguration<TAgent>
{
    public void Configure(EntityTypeBuilder<TAgent> builder)
    {
        builder.HasKey(ii => new { ii.SuiteId, ii.CorpId });
    }
}

